home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWTPtrVector.z / RWTPtrVector
Encoding:
Text File  |  2002-10-03  |  6.5 KB  |  199 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                          RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTPtrVector<T> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/tpvector.h>
  13.  
  14.  
  15.  
  16.               RWTPtrVector<T> vec;
  17.  
  18.  
  19.  
  20.  
  21. DDDDeeeessssccccrrrriiiippppttttoooonnnn
  22.      Class RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr<<<<TTTT>>>> is a simple parameterized vector of pointers to
  23.      objects of type TTTT.  It is most useful when you know precisely how many
  24.      pointers must be held in the collection.  If the intention is to "insert"
  25.      an unknown number of objects into a collection, then class
  26.      RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr<<<<TTTT>>>> may be a better choice.  The class TTTT can be of any
  27.      type.
  28.  
  29. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  30.      Isomorphic
  31.  
  32. EEEExxxxaaaammmmpppplllleeee
  33.               #include <rw/tpvector.h>
  34.           #include <rw/rwdate.h>
  35.           #include <rw/rstream.h>
  36.           main()  {
  37.             RWTPtrVector<RWDate> week(7);
  38.             RWDate begin;   // Today's date
  39.             for (int i=0; i<7; i++)
  40.               week[i] = new RWDate(begin++);
  41.             for (i=0; i<7; i++)
  42.             {
  43.               cout << *week[i] << endl;
  44.               delete week[i];
  45.             }
  46.             return 0;
  47.           }
  48.  
  49.  
  50.      Program output:
  51.  
  52.               March 16, 1996
  53.           March 17, 1996
  54.           March 18, 1996
  55.           March 19, 1996
  56.           March 20, 1996
  57.           March 21, 1996
  58.           March 22, 1996
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                          RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  75.               RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr<<<<TTTT>>>>();
  76.  
  77.  
  78.      Constructs an empty vector of length zero.
  79.  
  80.               RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr<<<<TTTT>>>>(size_t n);
  81.  
  82.  
  83.      Constructs a vector of length nnnn.  The initial values of the elements are
  84.      undefined.  Hence, they can (and probably will) be garbage.
  85.  
  86.               RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr<<<<TTTT>>>>(size_t n, T* ival);
  87.  
  88.  
  89.      Constructs a vector of length nnnn, with each element pointing to the item
  90.      ****iiiivvvvaaaallll.
  91.  
  92.               RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr<<<<TTTT>>>>(const RWTPtrVector& v);
  93.  
  94.  
  95.      Constructs self as a shallow copy of vvvv.  After construction, pointers
  96.      held by the two vectors point to the same items.
  97.  
  98. PPPPuuuubbbblllliiiicccc ooooppppeeeerrrraaaattttoooorrrrssss
  99.               RWTPtrVector<T>&
  100.           ooooppppeeeerrrraaaattttoooorrrr====(const RWTPtrVector<T>& v);
  101.  
  102.  
  103.      Sets self to a shallow copy of vvvv.  Afterwards, the two vectors will have
  104.      the same length and pointersheld by the two vectors will point to the
  105.      same items.
  106.  
  107.               RWTPtrVector<T>&
  108.           ooooppppeeeerrrraaaattttoooorrrr====(T* p);
  109.  
  110.  
  111.      Sets all elements in self to point to the item ****pppp.
  112.  
  113.               T*&
  114.           ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i);
  115.           T*
  116.           ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i) const;
  117.  
  118.  
  119.      Returns the iiiith value in the vector.  The first variant can be used as an
  120.      l-value, the second cannot.  The index iiii must be between zero and the
  121.      length of the vector, less one.  No bounds checking is performed.
  122.  
  123.               T*&
  124.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i);
  125.           T*
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                                          RRRRWWWWTTTTPPPPttttrrrrVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i) const;
  141.  
  142.  
  143.      Returns the iiiith value in the vector.  The first variant can be used as an
  144.      lvalue, the second cannot.  The index iiii must be between zero and the
  145.      length of the vector, less one; or an exception of type TTTTOOOOOOOOLLLL____IIIINNNNDDDDEEEEXXXX will
  146.      be thrown.
  147.  
  148. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  149.               T* const *
  150.           ddddaaaattttaaaa() const;
  151.  
  152.  
  153.      Returns a pointer to the raw data of the vector.  Should be used with
  154.      care.
  155.  
  156.               size_t
  157.           lllleeeennnnggggtttthhhh() const;
  158.  
  159.  
  160.      Returns the length of the vector.
  161.  
  162.               void
  163.           rrrreeeesssshhhhaaaappppeeee(size_t N);
  164.  
  165.  
  166.      Changes the length of the vector to NNNN.  If this results in the vector
  167.      being lengthened, then the initial value of the additional elements is
  168.      undefined.
  169.  
  170.               void
  171.           rrrreeeessssiiiizzzzeeee(size_t N);
  172.  
  173.  
  174.      Changes the length of the vector to NNNN.  If this results in the vector
  175.      being lengthened, then the initial value of the additional elements is
  176.      set to nnnniiiillll.
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.